package ch03sz;

//工厂类
public class OptionerFactory {
    public static Operation createOptioner(String option) {
        Operation operation=null;
        switch (option) {
            case "+":
                operation = new Add();
                break;
            case "-":
                operation = new Sub();
                break;
            case "*":
                operation = new Mul();
                break;
            case "/":
                operation = new Div();
                break;
            case "%":
                operation = new Rem();
                break;
            default :
              throw new RuntimeException("不支持"+option+"作为运算符使用");
        }
        return operation;
    }


}
